//
//  ShowCollectionCell.m
//  BusinessMarket
//
//  Created by Michael Li on 2018/10/30.
//  Copyright © 2018年 Michael Li. All rights reserved.
//

#import "ShowCollectionCell.h"
#import "HomeModel.h"
#import "ReleaseModel.h"
#define kDefTitleCor [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1]
@interface ShowCollectionCell()
@property(nonatomic,strong) UILabel *cellLabel;
//@property(nonatomic,assign) NSInteger show;
@end
@implementation ShowCollectionCell

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.contentView.backgroundColor = [UIColor whiteColor];
//        self.cellBtn = [[UIButton alloc]initWithFrame:CGRectMake(self.contentView.frame.size.width*0.1, 7, self.contentView.frame.size.width*0.8, 30)];
//         [self.cellBtn setTitleColor:kLabel102Color forState:UIControlStateNormal];

//        self.cellBtn.titleLabel.font = [UIFont systemFontOfSize:14];
//        self.cellBtn.layer.masksToBounds = YES;
//        self.cellBtn.layer.cornerRadius = 15;
//        self.cellBtn.layer.borderColor  = kLineColor.CGColor;
//        self.cellBtn.layer.borderWidth  = 1;
//        [self.cellBtn setTitleColor:[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1] forState:UIControlStateNormal];
//        [self.cellBtn setTitleColor:kDefTitleCor forState:UIControlStateNormal];
//        [self.cellBtn setTitleColor:kOrangeBg forState:UIControlStateSelected];
//        [self.contentView addSubview:self.cellBtn];
//        [self.cellBtn addTarget: self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
        
        self.cellLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.contentView.frame.size.width*0.1, 7, self.contentView.frame.size.width*0.8, 30)];
        [self.contentView addSubview:self.cellLabel];
        self.cellLabel.font = [UIFont systemFontOfSize:12];
        self.cellLabel.textAlignment = NSTextAlignmentCenter;
        self.cellLabel.layer.masksToBounds = YES;
        self.cellLabel.layer.cornerRadius = 3;
//        self.cellLabel.layer.borderColor = kLineColor.CGColor;
//        self.cellLabel.textColor = kLabel153Color;
//        self.cellLabel.backgroundColor = kLabel102Color;
//        self.cellLabel.backgroundColor = kLabel244Color;
        
        
    }
    return self;
}

- (void)setHomeModel:(HomeModel *)homeModel
{
    _homeModel = homeModel;
    self.cellLabel.layer.cornerRadius = 15;
    if (homeModel.show) {
//    [self.cellBtn setTitleColor:kOrangeBg forState:UIControlStateNormal];
//        self.cellBtn.layer.borderColor  = kOrangeBg.CGColor;
        self.cellLabel.backgroundColor = kOrangeBg;
        self.cellLabel.textColor = kWhite;
    }else {
//        [self.cellBtn setTitleColor:kDefTitleCor forState:UIControlStateNormal];
//        self.cellLabel.backgroundColor = kDefTitleCor;
//        self.cellLabel.layer.borderColor = kLineColor.CGColor;
        self.cellLabel.textColor = kLabel102Color;
        self.cellLabel.backgroundColor = kLabel244Color;
    }
    self.cellLabel.text = homeModel.content;
//    [self.cellBtn setTitle:homeModel.content forState:UIControlStateNormal];
}
- (void)setReleaseModel:(ReleaseModel *)releaseModel
{
    _releaseModel = releaseModel;
//    [self.cellBtn setTitle:releaseModel.content forState:UIControlStateNormal];
    self.cellLabel.text = releaseModel.content;
    if (releaseModel.show) {
        self.cellLabel.backgroundColor = kOrangeBg;
        self.cellLabel.textColor = kWhite;
        self.cellLabel.layer.borderColor = kOrangeBg.CGColor;
        self.cellLabel.layer.borderWidth = 0.1;
    }else {
        self.cellLabel.backgroundColor = kLabel244Color;
        self.cellLabel.textColor = kLabel102Color;
        self.cellLabel.layer.borderColor = kLabel244Color.CGColor;
        self.cellLabel.layer.borderWidth = 0.5;
    }
}
//- (void)setDataMuta:(NSArray *)dataMuta
//{
//    _dataMuta = dataMuta;
////    [self.cellBtn setTitle:dataMuta[self.indexPath.row] forState:UIControlStateNormal];
//}
- (void)setIndexPath:(NSIndexPath *)indexPath
{
    _indexPath = indexPath;
//    self.cellBtn.tag = indexPath.row;
//    if (indexPath.row == 0) {
//
//        self.releaseModel.show = YES;
//    }
//    XLog(@"self.show:%ld",self.show);
//    if (!self.model.show) {
//        if (indexPath.row == 0) {
//            self.cellBtn.backgroundColor =kOrangeBg;
//            [self.cellBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        }else {
//            //       self.model.showView = YES;
//            self.cellBtn.backgroundColor =kLineColor;
//            [self.cellBtn setTitleColor:kLabel153Color forState:UIControlStateNormal];
//        }
    
//    }
}
-(void)clickBtn:(UIButton *)clickBtn
{
//    XLog(@"clickBtn:%ld",self.indexPath.row);
//    self.show = self.indexPath.row;
//    clickBtn.selected = YES;

    if ([self.delegate respondsToSelector:@selector(showCollectionCell:withBtn:)]) {
        [self.delegate showCollectionCell:self withBtn:clickBtn];
    }
    
}
@end
